# coding=utf-8
# -*- coding: UTF-8 -*-
#
# This file is part of the kernelstudio package.
#
# (c) 2014-2025 zlin <admin@kernelstudio.com>
#
# For the full copyright and license information, please view the LICENSE file
# that was distributed with this source code.

from gevent.pywsgi import WSGIServer

from factory import create_application

app = create_application()

if __name__ == '__main__':

    port = app.config.get("APP_PORT", 4444)
    host = app.config.get("APP_HOST", "0.0.0.0")

    app.logger.info(f"Starting server on {host}:{port}")

    if app.debug:
        app.run(host=host, port=port, debug=True)
    else:
        server = WSGIServer((host, port), app)
        server.serve_forever()
